All Packages Class Hierarchy This Package Previous Next Index
Class sun.servlet.http.HttpResponse
java.lang.Object
|
+----sun.servlet.http.HttpResponse
- public class HttpResponse
- extends Object
- implements HttpServletResponse, Observer
This class represents an HTTP servlet response.
-
bufHeader
- The buffer used to set the header buffer.
-
con
- The connection for this servlet.
-
contentLenSet
-
-
headerBytes
- The response header size in bytes.
-
headers
- The message headers for this response.
-
keepAlive
- Set to true when keep-alive is enabled.
-
out
- The output stream for writing response data.
-
outHeader
- The output stream for writing headers.
-
protocol
- The protocol of the response.
-
reason
- The status message of the response.
-
status
- The status code of the response.
-
HttpResponse()
- Creates a new HttpResponse object.
-
containsHeader(String)
- Returns true if the specified header field is contained in this response
otherwise returns false.
-
finish()
- Finishes the response.
-
getEntityBytes()
- Returns the size of the entity data for this response.
-
getHeaders()
- Returns the message header for this response.
-
getKeepAlive()
- Returns true if this connection should be kept alive.
-
getOutputStream()
- Returns an output stream for writing response data.
-
getStatus()
- Returns the status code of the response.
-
getTotalBytes()
- Returns the total number of bytes for this response.
-
init(ServletConnection)
- Initializes this response with the specified servlet connection.
-
next()
- Begins the next response.
-
reason(int)
- Returns a default reason phrase for the specified status code.
-
reset()
- Resets the servlet response.
-
sendError(int)
- Sends an error response to the client using the specified status
code and no default message.
-
sendError(int, String)
- Sends an error response to the client using the specified status
code and detail message.
-
sendRedirect(String)
- Sends a redirect response to the client using the specified redirect
location URL.
-
setContentLength(int)
- Defines the content length for this response.
-
setContentType(String)
- Defines the content type for this response.
-
setDateHeader(String)
- Adds a date header to the current time.
-
setDateHeader(String, long)
- Adds a date header with the specified time.
-
setHeader(String, String)
- Adds a header field with the specified string value.
-
setIntHeader(String, int)
- Adds a header field with the specified integer value.
-
setKeepAlive(boolean)
- Used to indicate whether this connection should be kept alive.
-
setProtocol(String)
- Sets the protocol of the response.
-
setStatus(int)
- Sets the status code and a default message for this response.
-
setStatus(int, String)
- Sets the status code and message for this response.
-
update(Observable, Object)
- This method is called for a full request when the servlet first writes
to the output stream.
-
writeHeaders()
-
status
protected int status
- The status code of the response.
reason
protected String reason
- The status message of the response.
protocol
protected String protocol
- The protocol of the response.
headers
protected final MimeHeaders headers
- The message headers for this response.
out
protected HttpOutputStream out
- The output stream for writing response data.
outHeader
protected HttpOutputStream outHeader
- The output stream for writing headers.
bufHeader
protected ByteArrayOutputStream bufHeader
- The buffer used to set the header buffer.
con
protected ServletConnection con
- The connection for this servlet.
headerBytes
protected int headerBytes
- The response header size in bytes.
keepAlive
protected boolean keepAlive
- Set to true when keep-alive is enabled.
contentLenSet
protected boolean contentLenSet
HttpResponse
public HttpResponse()
- Creates a new HttpResponse object.
init
public void init(ServletConnection con) throws IOException
- Initializes this response with the specified servlet connection.
- Parameters:
- con - the servlet connection
next
public void next()
- Begins the next response.
finish
public void finish() throws IOException
- Finishes the response.
reset
public void reset()
- Resets the servlet response.
getTotalBytes
public int getTotalBytes()
- Returns the total number of bytes for this response.
getEntityBytes
public int getEntityBytes()
- Returns the size of the entity data for this response.
setProtocol
public void setProtocol(String protocol)
- Sets the protocol of the response. Should be called immediately after
initializing the response.
setKeepAlive
public void setKeepAlive(boolean enable)
- Used to indicate whether this connection should be kept alive.
- Parameters:
- enable - if true then keep connection alive
getKeepAlive
public boolean getKeepAlive()
- Returns true if this connection should be kept alive.
setContentLength
public void setContentLength(int len)
- Defines the content length for this response. This call must
only be made once. Not setting the content length may
cause significant performance degradation.
- Parameters:
- len - the content length
setContentType
public void setContentType(String type)
- Defines the content type for this response. This call must
only be made once.
- Parameters:
- type - the content type
getOutputStream
public ServletOutputStream getOutputStream()
- Returns an output stream for writing response data.
setStatus
public void setStatus(int status,
String reason)
- Sets the status code and message for this response.
- Parameters:
- status - the status code
- reason - the status message
setStatus
public void setStatus(int status)
- Sets the status code and a default message for this response.
- Parameters:
- status - the status code
getStatus
public int getStatus()
- Returns the status code of the response.
setHeader
public void setHeader(String name,
String s)
- Adds a header field with the specified string value. If this is
called more than once, the current value will replace the previous value.
- Parameters:
- name - the header field name
- s - the field's string value
setIntHeader
public void setIntHeader(String name,
int i)
- Adds a header field with the specified integer value. If this is
called more than once, the current value will replace the previous value.
- Parameters:
- name - the header field name
- i - the field's integer value
setDateHeader
public void setDateHeader(String name,
long t)
- Adds a date header with the specified time. If this is called
called more than once, the current value will replace the previous value.
- Parameters:
- name - the header field name
- t - the time in milliseconds since the epoch
setDateHeader
public void setDateHeader(String name)
- Adds a date header to the current time. If this is called
called more than once, the current value will replace the previous value.
- Parameters:
- name - the header name
containsHeader
public boolean containsHeader(String name)
- Returns true if the specified header field is contained in this response
otherwise returns false.
- Parameters:
- name - the header field name
getHeaders
public MimeHeaders getHeaders()
- Returns the message header for this response.
reason
protected String reason(int status)
- Returns a default reason phrase for the specified status code.
sendError
public void sendError(int status,
String msg) throws IOException
- Sends an error response to the client using the specified status
code and detail message.
- Parameters:
- status - the status code
- msg - the detail message
- Throws: IOException
- if an I/O error has occurred
sendError
public void sendError(int status) throws IOException
- Sends an error response to the client using the specified status
code and no default message.
- Parameters:
- sc - the status code
- Throws: IOException
- if an I/O error has occurred
sendRedirect
public void sendRedirect(String location) throws IOException
- Sends a redirect response to the client using the specified redirect
location URL.
- Parameters:
- location - the redirect location URL
- Throws: IOException
- if an I/O error has occurred
update
public void update(Observable obs,
Object obj)
- This method is called for a full request when the servlet first writes
to the output stream. This allows the HTTP headers to be written before
the response entity data.
writeHeaders
protected void writeHeaders() throws IOException
All Packages Class Hierarchy This Package Previous Next Index